<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base = "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
    <input type="hidden" id="id" name="id" value="${questionnaire.id!}">
    <div class="layui-form-item">
        <label class="layui-form-label">问卷标题</label>
        <div class="layui-input-block">
            <input type="text" id="questionnaireTitle" name="questionnaireTitle" value="${questionnaire.questionnaireTitle!}" autocomplete="off"
                   placeholder="请输入问卷标题"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户ID </label>
        <div class="layui-input-block">
            <input type="text" id="userId" name="userId" value="${questionnaire.userId!}" autocomplete="off"
                   placeholder="请输入用户ID "
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">创建时间</label>
        <div class="layui-input-block">
            <input type="text" id="createTime" name="createTime" value="${questionnaire.createTime!}" autocomplete="off"
                   placeholder="请输入创建时间"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">更新时间</label>
        <div class="layui-input-block">
            <input type="text" id="updateTime" name="updateTime" value="${questionnaire.updateTime!}" autocomplete="off"
                   placeholder="请输入更新时间"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">0正常 1停用</label>
        <div class="layui-input-block">
            <input type="text" id="delFlag" name="delFlag" value="${questionnaire.delFlag!}" autocomplete="off"
                   placeholder="请输入0正常  1停用"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">0未发布/1发布/2停用</label>
        <div class="layui-input-block">
            <input type="text" id="status" name="status" value="${questionnaire.status!}" autocomplete="off"
                   placeholder="请输入0未发布/1发布/2停用"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">问卷类型/1调查/2考试</label>
        <div class="layui-input-block">
            <input type="text" id="questionnaireType" name="questionnaireType" value="${questionnaire.questionnaireType!}"
                   autocomplete="off" placeholder="请输入0未发布/1发布/2停用"
                   class="layui-input">
        </div>
    </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form
            , layer = layui.layer;
        $("#submit").on("click", function () {
            if (check() === false) {
                return;
            }

            var formDate = {
                id: $("#id").val(),
                topicTitle: $("#questionnaireTitle").val(),
                userId: $("#userId").val(),
                createTime: $("#createTime").val(),
                updateTime: $("#updateTime").val(),
                delFlag: $("#delFlag").val(),
                status: $("#status").val(),
                questionnaireType: $("#questionnaireType").val()
            }
            $.ajax({
                type: "POST",
                url: base + "/papersstar/questionnaire/admin/editQuestionnaire",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href = base + "/papersstar/questionnaire/admin/main.html"
                    } else {

                    }
                }
            });
        })


        function check() {
            if ($("#questionnaireTitle").val().length < 1) {
                layer.msg("请输入问卷标题");
                return false;
            }
            if ($("#userId").val().length < 1) {
                layer.msg("请输入用户ID ");
                return false;
            }
            if ($("#createTime").val().length < 1) {
                layer.msg("请输入创建时间");
                return false;
            }
            if ($("#updateTime").val().length < 1) {
                layer.msg("请输入更新时间");
                return false;
            }
            if ($("#delFlag").val().length < 1) {
                layer.msg("请输入0正常  1停用");
                return false;
            }
            if ($("#status").val().length < 1) {
                layer.msg("请输入0未发布/1发布/2停用");
                return false;
            }
        }
    });

</script>
</body>
</html>